﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Globalization;
using Telerik.Web.UI;
using KPIS.GERP.GHRMS.BLL;
using KPIS.GERP.GHRMS.IBLL;
using KPIS.GERP.GHRMS.MODEL;

namespace KPIS.GERP.GHRMS.APP.App_UI.UserControls
{
    public partial class CMD_FieldPositionInfo : System.Web.UI.UserControl
    {
        private IFieldBLL fBLL = new FieldBLL();
        private IClassBLL cBLL = new ClassBLL();
        private IPositionTypeBLL ptBLL = new PositionTypeBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }
        public void bindClasscombo()
        {
            IList<ClassInfo> infoList = cBLL.ListClasses(posTypeCombo.SelectedValue);
            
            classCombo.DataSource = infoList;
            classCombo.DataBind();
        }

        public void bindPosTypeCombo()
        {
            IList<PositionTypeInfo> infoList = ptBLL.ListPositionTypes(Convert.ToInt32(Session["EMPTYPE"].ToString()));

            posTypeCombo.DataSource = infoList;
            posTypeCombo.DataBind();
        }
        protected void btnFindPos_Click(object sender, ImageClickEventArgs e)
        {
            string st = HidePos.Value;
            if (st == "")
                return;
            
            IList<FieldInfo> infoList = fBLL.ListFields(st);

            if (infoList.Count > 0)
            {
                txtPosition.Text = infoList[0].LineName;
                bindPosTypeCombo();
                posTypeCombo.SelectedValue = infoList[0].PositionTypes.Sequence.ToString();
                bindClasscombo();
            }
        }
        protected void btnFindPos_Load(object sender, EventArgs e)
        {
            btnFindPos.Attributes.Add("OnClick", "LinkMDdetail(" + HidePos.ClientID + "," + "'Forms/DialogFieldPositions.aspx','../frmIframe.html',700,500)");
        }

        protected void posTypeCombo_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            bindClasscombo();
        }

        protected void classCombo_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
        {

        }

        protected void posTypeCombo_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
        {
            bindPosTypeCombo();
        }
        protected void classCombo_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
        {
            bindClasscombo();
        }
    }
}